package com.bawei.rk_01.Room

import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase

//数据库升级策略
val Migration_1_2  = object : Migration(1,2){
    override fun migrate(database: SupportSQLiteDatabase) {
        //执行数据库升级事件，包括新增表 或 对某一表增加字段
        database.execSQL("CREATE TABLE money(userid INTEGER PRIMARY KEY NOT NULL ,money FLOAT NOT NULL)")
    }

}

val Migration_2_3 = object : Migration(2,3) {
    override fun migrate(database: SupportSQLiteDatabase) {
        database.execSQL("CREATE TABLE live(id INTEGER PRIMARY KEY NOT NULL,name STRING NOT NULL , IMAGE STRING NOT NULL)")
    }

}

val Migration_3_4 = object : Migration(3,4) {
    override fun migrate(database: SupportSQLiteDatabase) {
        database.execSQL("create table user(id Integer primary key not null , name String not null)")
    }

}